package cloud.maque.admin.controller;

import cloud.maque.admin.annotations.TenantId;
import cloud.maque.admin.annotations.TenantQuery;
import cloud.maque.admin.domain.entity.MqRole;
import cloud.maque.admin.domain.vo.RoleVo;
import cloud.maque.admin.service.MqRoleService;
import cloud.maque.framework.common.request.PaginateDataResquest;
import cloud.maque.framework.common.response.ResponseBodyVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 角色接口
 *
 * @author zhuyf
 * @date 2023/3/17 20:57
 */
@RestController
@RequestMapping(value = "/role")
@Api(tags = "运维-角色接口")
public class RoleController {


    @Autowired
    MqRoleService roleService;


    @PostMapping("/list")
    @ApiOperation(value = "角色查询")
    @TenantQuery
    public ResponseBodyVo<PageInfo<MqRole>> page(@RequestBody @ApiParam("查询内容") PaginateDataResquest<MqRole> pageReq) {
        return ResponseBodyVo.Success(roleService.page(pageReq));
    }

    @GetMapping("/detail")
    @ApiOperation(value = "角色详情")
    public ResponseBodyVo<RoleVo> Detail(@RequestParam("id") String roleId) {
        return ResponseBodyVo.Success(roleService.getDetail(roleId));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增或修改")
    public ResponseBodyVo<RoleVo> save(@RequestBody @ApiParam("内容") RoleVo mqRole) {

        return ResponseBodyVo.Success(roleService.saveRole(mqRole));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "角色删除")
    @TenantQuery
    public ResponseBodyVo<Boolean> Delete(@PathVariable("id") String menuId, @TenantId String tenantId) {
        return ResponseBodyVo.Success(roleService.delete(menuId, tenantId));
    }


}
